import 'package:flutter/material.dart';
import 'package:uikit/utils/screen_util/size_extension.dart';

import 'anchor_image.dart';

/// 作者：李佳奇
/// 日期：2022/3/15
/// 备注：

class DefaultTagPainter extends CustomPainter {
  DefaultTagPainter(this.params);

  final DefaultAnchorWidget params;

  ///链接横线的朝向
  bool get line2Left => params.markerAtRight;

  ///线高
  final double lineHeight = 1.w;

  static final Paint _paint = Paint()
    ..color = Colors.white
    ..style = PaintingStyle.fill;

  final double adjustV = 2.w;

  @override
  void paint(Canvas canvas, Size size) {
    final Offset center = Offset(size.width / 2, size.height / 2);

    canvas.drawCircle(center, 2.5.w, _paint);
    final double lineLen = params.space + params.tagHorizontalPadding + adjustV;
    if (line2Left) {
      canvas.drawRect(Rect.fromLTWH(center.dx - 2.5.w - lineLen, center.dy - lineHeight / 2, lineLen, lineHeight), _paint);
    } else {
      canvas.drawRect(Rect.fromLTWH(center.dx + 2.5.w, center.dy - lineHeight / 2, lineLen, 1.w), _paint);
    }
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}
